import React from "react";
export default class Child extends React.Component {
    //构造函数
    constructor(props) {
        super(props);
        this.state = {
            count: 0
        }
    }
    componentWillMount() {
        console.log('will mount')
    }
    componentDidMount() {
        console.log('did mount')
    }
    componentWillReceiveProps(nextProps, nextContext) {
        console.log('will receive props'+nextProps.name)
    }
    //调用setState将更新
    shouldComponentUpdate(nextProps, nextState, nextContext) {
        console.log('should update')
        return true
    }
    componentWillUpdate(nextProps, nextState, nextContext) {
        console.log('will update')
    }
    componentDidUpdate(prevProps, prevState, snapshot) {
        console.log('did update')
    }

    render() {
        return <div>
            <p>这是子组件的生命周期</p>
            <p>{this.props.name}</p>
        </div>
    }
}